home *** CD-ROM | disk | FTP | other *** search
- /*
- * illustrate the use of memory and string routines
- *
- * Alternative to index.c:
- * If _ABI_SOURCE is defined, change the code
- */
-
- #ifdef _ABI_SOURCE
- #include <string.h>
- #define ANSI_STRING
- #else
- #include <strings.h>
- #endif
- #ifdef _ABI_SOURCE
- #include <memory.h>
- #endif
- #include <stdio.h>
-
- #ifndef _ABI_SOURCE
- extern int bcmp ();
- extern void bzero ();
- extern void bcopy ();
- #endif
-
-
- #define BUFFER 256
- char *string = "this is a test";
- char buf[BUFFER];
-
- main ()
- {
- int rv;
- char *cp;
-
- #ifdef _ABI_SOURCE
- memset (buf, 0, BUFFER);
- #else
- bzero (buf, BUFFER);
- #endif
- #ifdef _ABI_SOURCE
- memcpy (buf, string, strlen(string));
- #else
- bcopy (string, buf, strlen(string));
- #endif
- #ifdef _ABI_SOURCE
- rv = memcmp (string, buf, strlen(string));
- #else
- rv = bcmp (string, buf, strlen(string));
- #endif
- if ( rv == 0 )
- printf ("Copied strings match\n");
- #ifdef _ABI_SOURCE
- cp = strchr (buf, 'a');
- #else
- cp = index (buf, 'a');
- #endif
- if (cp != NULL)
- printf ("Found character in string\n");
-
- }
-